// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import MarqueeText from 'vue-marquee-text-component'
// 引入axios
import axios from 'axios'
//引入elementui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';


Vue.component('marquee-text', MarqueeText)
// 添加请求拦截器
axios.interceptors.request.use(req=>{
    // 在发送请求之前做些什么
    let url = req.url
    if(url!="/addAccount"&&url!="/userInfo/getCollectRankList"){
      req.headers['token']=localStorage.getItem("token")
      if(url=="/userInfo/login"&&url=="/account/login"&&localStorage.getItem("token")==null){
        req.headers['token']="1"
      }
      console.log("请求携带的token>>>>>>>>>>>>>>>>>"+localStorage.getItem("token"))
    }
    return req;
  })
  //添加响应拦截器
  axios.interceptors.response.use(resp=>{
      // 在接受响应之前做些什么
      if(resp.headers['token']!=undefined){
       localStorage.setItem("token",resp.headers['token'])
       console.log("响应收到的token>>>>>>>>>>>>>>>>>"+localStorage.getItem("token"))
      }
      return resp;
    })


//将axios挂载到vue的原型对象上
Vue.prototype.$http=axios
Vue.use(ElementUI)
Vue.config.productionTip = false

axios.defaults.baseURL="http://192.168.20.27:9001"

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
